<?php
session_start();
include_once 'functions/function.php';
include_once 'functions/index.class.php';



if(isset($_SESSION['id'])){
    
    
    //header("location:javascript://history.go(0)");
    
}






if(isset($_POST['email']) AND isset($_POST['password'])){
    
    
    
   $index = new index($_POST['email'], $_POST['password']);
   
   $error = $index->verify();
    
    if($error == "ok"){
        
        if($index->checkexistance()=="ok"){
            
            if($index->session()==1){
                
                header('Location: home.php');
            }
            else{
                
                header('Location: adminHome.php');
            }
            
        }
        else{
            
            $error = $index->checkexistance();
            $display = $error;
        }
        
    }
    else{
        
        $display = $error;
    }
    
}
?>

<!DOCTYPE html>
<html>
    <head>
		<link rel="stylesheet" href="css/index.css">
	</head >
	
	
	<body style="background: url(images/background.jpg);">
	
	
		<div id="wrapper">
                    
                     <div id="head">
		
                       <span>Not yet a member? <a class="newAccount" href="newAccount.php">Sign Up Here!</a></span>
                       <span>Forgot Password? <a class="newAccount" href="resetPassword.php">Reset Here!</a></span>
		
                    </div>
	
		<div id="container">
                    
                   
		
			<img src="images/spsu.png" style="height: 35%; width: 40%; margin-left: 30%;">
	
			<div id="discussion">
	
			<h3 class="WaggleTopic">Sign in to Waggle</h3>
			
			<hr/>
			<form id="form1" action="index.php" method="post" >
			
				<table style="border: 0px;" cellspacing="20">
				
					<tr>
						<td><label class="label">SPSU Email</label></td>
						<td><input id ="user" name="email" type="text" size="30"></td>
					</tr>
                                        
					<tr>
						<td><label class="label">Password</label></td>
						<td><input id ="pass" name="password" type="password"></td>
					</tr>
				</table>
		

				
				<table>
				
					<tr>
						<td colspan="2"><input id="signIn" type="submit" value="Log in"></td>
					</tr>
					<tr></tr>
                                        <tr>
                                            <td colspan="2" id="error">
                                                <?php
                                                
                                                if(isset($display)){
                                                    
                                                    echo $display;
                                                }
                                                
                                                ?>
                                                
                                                
                                            </td>
                                        </tr>
				</table>
			
			<form>
			
			
			<div>
	
	
		</div>
		
		</div>
		
		
	
	</body>
</html>